package com.yanqu.road.server.channelserver.manager.xrank;

import com.yanqu.road.logic.helper.SeasonHelper;
import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.logic.xlogic.rank.channel.XChannelRankMap;
import com.yanqu.road.logic.xlogic.rank.season.XSeasonUserRankMap;
import com.yanqu.road.logic.xlogic.rank.season.stage.XSeasonStageUserRankMap;
import com.yanqu.road.logic.xlogic.rank.user.XUserRankMap;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.channelserver.manager.activity.ChannelActivityInfoMgr;

public class ChannelXRankMgr extends TempMgr {

    private static XChannelRankMap channelRankMap = new XChannelRankMap(DbNameStrategy.getChannelServerDb(), "t_n_xrank_channel_part",
            ChannelActivityInfoMgr::getChannelActivityMaxRank,
            ChannelActivityInfoMgr::getChannelRankPartNum);

    private static XUserRankMap userRankMap = new XUserRankMap(DbNameStrategy.getChannelServerDb(), "t_n_xrank_user",
            ChannelActivityInfoMgr::getChannelActivityMaxRank);

    private static XSeasonUserRankMap seasonUserRankMap = new XSeasonUserRankMap(DbNameStrategy.getChannelServerDb(), "t_n_xrank_season_user",
            SeasonHelper::getChannelSeasonMaxRank);

    private static XSeasonStageUserRankMap seasonStageUserRankMap = new XSeasonStageUserRankMap(DbNameStrategy.getChannelServerDb(), "t_n_xrank_season_stage_user",
            SeasonHelper::getChannelSeasonMaxRank);

    public static XChannelRankMap getChannelRankMap() {
        return channelRankMap;
    }

    public static XUserRankMap getUserRankMap() {
        return userRankMap;
    }

    public static XSeasonUserRankMap getSeasonUserRankMap() {
        return seasonUserRankMap;
    }

    public static XSeasonStageUserRankMap getSeasonStageUserRankMap() {
        return seasonStageUserRankMap;
    }

    @Override
    public boolean save() {
        userRankMap.save();
        channelRankMap.save();
        seasonUserRankMap.save();
        seasonStageUserRankMap.save();
        return true;
    }

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }
}
